home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / rettig.arc / TRSOURCE.EXE / PEEKBYTE.C < prev    next >
C/C++ Source or Header  |  1990-10-22  |  822b  |  39 lines

  1. /*********
  2. * PEEKBYTE.C
  3. *
  4. * by Leonard Zerman
  5. *
  6. * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  7. *
  8. *********/
  9.  
  10. #include <dos.h>
  11.  
  12. #include "nandef.h"
  13. #include "extend.h"
  14.  
  15. CLIPPER PEEKBYTE()
  16. {
  17.    int num;
  18.    unsigned int segment;
  19.    unsigned int offset;
  20.    unsigned char far * fptr;
  21.    char retbuff[3];
  22.  
  23.    if(PCOUNT == 2 && ISCHAR(1) && (ISCHAR(2) || ISNUM(2)))
  24.    {
  25.       segment = _tr_htoi(_parc(1));
  26.       offset  = ISNUM(2) ? _parni(2) : _tr_htoi(_parc(2));
  27.       fptr    = MK_FP(segment, offset);
  28.  
  29.       retbuff[2] = '\0';
  30.       num        = *fptr % 16;
  31.       retbuff[1] = num < 10 ? num + '0' : (num - 10) + 'A';
  32.       num        = *fptr / 16;
  33.       retbuff[0] = num < 10 ? num + '0' : (num - 10) + 'A';
  34.       _retc(retbuff);
  35.    }
  36.    else
  37.       _retc("-1");
  38. }
  39.